﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Group
    {
            [Description("ID")]
            public long ID{get;set;}
            [Description("GroupGuidID")]
            public string GroupGuidID{get;set;}
            [Description("Mã")]
            public string Code{get;set;}
            [Description("Tên")]
            public string Name{get;set;}
            [Description("Mô tả")]
            public string Description{get;set;}
            [Description("Kích hoạt")]
            public bool Active{get;set;}
          
         
        public Group()
        {       
                GroupGuidID =Guid.NewGuid().ToString();
                Code ="";   
                Name ="";   
                Description ="";   
        }

        public override string ToString()
        {
            return Name;
        }

       static Group DynamicCast<T>(object row_data, object row_header) where T : Group
       {
           // row_data : DataRow
           // row_header : DataColumnCollection
           Group ret = new Group();
           DataRow dt = (DataRow)row_data;

           foreach (DataColumn column in (DataColumnCollection)row_header)
           {
               switch (column.ColumnName)
               {
                      case  "ID":
                        ret.ID = ConvertObject.ToLong(dt[column]);
                       break;
                      case  "GroupGuidID":
                        ret.GroupGuidID = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Code":
                        ret.Code = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Name":
                        ret.Name = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Description":
                        ret.Description = ConvertObject.ToString(dt[column]);
                       break;
                      case  "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                       break;
                      
                   default:
                       break;
               }
           }

           return ret;
       }
        
    }
}
